import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class ResultFrame {
	JFrame jframe;
	public JLabel resultLabel;
	public JLabel errorDes;
	public JLabel iconLabel;

	ResultFrame(){
		jframe=new JFrame("ResultFrame");
		jframe.setBounds(300, 300, 600, 700);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setPreferredSize(new Dimension(550,500));
		jframe.getContentPane().add(scrollPane, BorderLayout.CENTER);
		
		JScrollPane scrollPaneIcon = new JScrollPane();
		scrollPaneIcon.setPreferredSize(new Dimension(25,500));
		jframe.getContentPane().add(scrollPaneIcon, BorderLayout.WEST);
		scrollPaneIcon.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		
		iconLabel = new JLabel();
		iconLabel.setPreferredSize(new Dimension(25,500));
		scrollPaneIcon.setViewportView(iconLabel);
			
		resultLabel = new JLabel();
		resultLabel.setVerticalAlignment(SwingConstants.TOP);
		resultLabel.setPreferredSize(new Dimension(550,500));
		scrollPane.setViewportView(resultLabel);
		
		JScrollPane scrollPaneError = new JScrollPane();
		scrollPaneError.setPreferredSize(new Dimension(600,200));
		jframe.getContentPane().add(scrollPaneError, BorderLayout.SOUTH);
		
		errorDes = new JLabel();
		errorDes.setPreferredSize(new Dimension(600,200));	
		scrollPaneError.setViewportView(errorDes);
		jframe.show();
	}
	
	public void setResult(String s){
		this.resultLabel.setText(s);
		char[] charArray=s.toCharArray();
		String iconString="<html>";
		for(int i=0; i<charArray.length; i++){
			if(charArray[i]=='<'){
				if(charArray[i+1]=='b'){
					i+=3;
					iconString+="<br>";
				}
				else if(charArray[i+1]=='f')	iconString+="x";
			}
		}
		iconString+="<br>";
		this.iconLabel.setText(iconString);
	}
	
	public void setErrorDes(String s){
		this.errorDes.setText(s);
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		ResultFrame rf=new ResultFrame();
		rf.setResult("<html>ssss<br>ssss<font color=\"red\">ttt</font><br><font color=" +
				"\"green\">sssss</font><br>sssss");
		rf.setErrorDes("sssssssss");

	}

}
